package park;

public class J16Ch05Printers {

	public static void main(String[] args) {
		
		J16Printer p = new J16Printer("중소기업","번들프린터","USB2.0");
		System.out.println(p.toString());
		
		J16InkJetPrinter ip = new J16InkJetPrinter("hp", "잉크젯프린터", "USB2.0");
		System.out.println(ip.toString());
		
		J16LaserPrinter lp = new J16LaserPrinter("캐논", "레이저프린터", "USB3.0");
		System.out.println(lp.toString());
		
		J16PrinterService ps = new J16PrinterService();
		ps.print(p);
		ps.print(ip);
		ps.print(lp);
		
	}//main

}//class

//클래스로 만들떄에는 기본값을 넣을 필요가 없음.
class J16Printer{
	
	private String maker;
	private String model;
	private String interfaces;
	private int counts;
	private int remains;
	
	public J16Printer(String maker , String model , String interfaces) {
		this.maker=maker;
		this.model=model;
		this.interfaces=interfaces;
	}
	
	public String getMaker() {
		return maker;
	}

	public void setMaker(String maker) {
		this.maker = maker;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getInterfaces() {
		return interfaces;
	}

	public void setInterfaces(String interfaces) {
		this.interfaces = interfaces;
	}

	public int getCounts() {
		return counts;
	}

	public void setCounts(int counts) {
		this.counts = counts;
	}

	public int getRemains() {
		return remains;
	}

	public void setRemains(int remains) {
		this.remains = remains;
	}

	@Override
	public String toString() {
		String result = "";
		result += maker + "/" + model + "/" + interfaces + "/" + counts + "/" +
		remains;
		return result;
	}
	
}

//부모클래스에 기본생성저가 정의되지 않았기 때문에 자식클래스에서 따로 생성자를 정의해둬야 함
class J16InkJetPrinter extends J16Printer{

	public J16InkJetPrinter(String maker, String model, String interfaces) {
		super(maker, model, interfaces);
	}
	
	
}//J16InkJetPrinter

class J16LaserPrinter extends J16Printer{

	public J16LaserPrinter(String maker, String model, String interfaces) {
		super(maker, model, interfaces);
		//super() - 부모 클래스의 생성자를 가르키는 말
		
	}
	
	
}


interface J16PrinterIService{
	
	void print(J16Printer p);
	
}

//잘 익혀둘것
class J16PrinterService
	implements J16PrinterIService{
	@Override
	public void print(J16Printer p) {
		String result = p.getMaker() + "가 문서를 출력합니다";
		System.out.println(result);
	}//print

}//J16PrinterService
